"""
嵌套列表
3个学生，5门课程，求每门课程的平均分和最大最小分
"""
import random

names = ['张三', '李四', '王五']
courses = ['语文', '数学', '英语', '体育', '科学']
# 嵌套列表，scores = [[74, 96, 51, 83, 77], [81, 75, 75, 77, 52], [66, 57, 56, 74, 95]]
scores = [[random.randrange(51, 100) for _ in range(len(courses))] for _ in range(len(names))]
print(scores)
# 求每个人的平均分
for i in range(len(names)):
    print(f'{names[i]}的平均分：{sum(scores[i]) / len(courses)}')

# 求每门课的最大值和最小值
for j in range(len(courses)):
    temp = [scores[i][j] for i in range(len(names))]
    print(f'{courses[j]}的最高分：{max(temp)}')
    print(f'{courses[j]}的最低分：{min(temp)}')
